#ifndef _UI_DROPDOWN_H_
#define _UI_DROPDOWN_H_

#include <vector>
#include "ui_widget.h"
namespace ui
{
class UIDropDown : public UIWidget
{
public:
/// stuff that every self-respecting widget should have
						UIDropDown(UIWidget* pParent,const std::string& Name = "");
	virtual				~UIDropDown();
	virtual bool		Create(const std::string& Name, const math::Vec2& Pos = math::Vec2(0.5f, 0.5f), const math::Vec2& Size= math::Vec2(0.1f, 0.1f));
	virtual	bool		Load(LuaPlus::LuaObject& _LObj);
	/// update
	virtual	bool		Tick(float dt);
	/// display
	virtual bool		Render(bool Force = false);
	/// register with LUA Bind
	static	void		Register(LuaPlus::LuaState* _pScript);

	//// specifics for dropdown
	bool				AddOption(const std::string Option);
	bool				ClickInside(const math::Vec2& Pos, const math::Vec2& From, const math::Vec2& Size);

	void				Clear() { m_Entries.resize(0); m_CurrentOption = -1;};
	bool				IsOpen() const { return m_Open; };
	int					GetSelected() const { return m_CurrentOption; };
	std::string			GetSelectedText();
	std::string			GetOriginalSelectedText();

	void				SetCurrentOption(int index);
	void				SetCurrentOptionFromTextW(const std::wstring& Text);
	void				SetCurrentOptionFromTextA(const std::string& Text);
	void				SetOpen(bool Val) { m_Open = Val; };
	virtual bool		OnMouseRelease(const math::Vec2& Pos, unsigned int Button);
	virtual bool		OnMouseDown(const math::Vec2& Pos, unsigned int Button);

	virtual void		SetPosition(const math::Vec2& Pos);
	virtual bool		IsInside(const math::Vec2& Pos);
	virtual UIWidget*	GetClone();
	virtual bool		IsImageValid();

	virtual void		SetTextA(const std::string& Text) { if (!m_CoversCompletely) UIWidget::SetTextA(Text); };
	virtual void		SetTextW(const std::wstring& Text){ if (!m_CoversCompletely) UIWidget::SetTextW(Text); };

	void				SetCurrentIndex(int index, bool Trigger);
	virtual void		RefreshText();
	virtual void		RefreshFonts();
protected:
	virtual bool		ExportSpecificsToFile(script::WriteLua*	pWL);

	std::vector<UIText>	m_Entries;	
	bool				m_Open;
	int					m_CurrentOption;
	math::Vec2			m_ButtonPos;
	math::Vec2			m_ButtonSize;
	bool				m_CoversCompletely;
};


}  //namespace ui

#endif // _UI_DROPDOWN_H_